package com.tgy.dao.role;

import com.tgy.dao.BaseDao;
import com.tgy.entity.Role;
import com.tgy.entity.SmbmsUser;
import org.junit.Test;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/***
 * @ClassName: RoleDaoImpl
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 17:43 2021/12/10
 * @version : V1.0
 */
public class RoleDaoImpl implements RoleDao{
    @Override
    public List<Role> getRole() {
        ResultSet resultSet = null;
        ArrayList<Role> roleList = new ArrayList<Role>();
        String sql = "select * from smbms_role";
        try {
            Connection c = BaseDao.getC();
            resultSet = BaseDao.execute(1, c, sql, null);
            while (resultSet.next()){
                Role role = new Role();
                role.setId(resultSet.getInt("id"));
                role.setRoleCode(resultSet.getString("roleCode"));
                role.setRoleName(resultSet.getString("roleName"));
                roleList.add(role);
            }
            BaseDao.closeResource(resultSet,null,c);

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return roleList;
    }
    @Test
    public void  aa(){
        List<Role> role = getRole();
        System.out.println(role);
    }
}
